new Vue({
    el: "#app",
    data() {
        return{
            count: 0,
            showCode:false,
            loginForm:{
                username:'',
                password:'',
                code:'',
                hasCode:false
            },

        }
    },
    methods:{
        loginBtn(){
            console.log(this.loginForm);
            this.count++;
            if (this.count==3){
                this.showCode = true;
            }
            $.ajax({
                url: "/user/login",
                data: {
                    "username": this.loginForm.username,
                    "password": this.loginForm.password,
                    "code": this.loginForm.code,
                    "hasCode":this.loginForm.hasCode
                },
                type:"post",
                dataType: "json",
                success:function (res) {
                    if (res.status){
                        lightyear.url('/');
                        lightyear.notify(res.msg,"success","1000","mdi mdi-checkbox-marked-circle");
                    }else {
                        lightyear.notify(res.msg,"danger","1000","mdi mdi-checkbox-marked-close");
                    }
                }
            });
        },

        flashCode(){
            this.src = '/user/getCode?d='+Math.floor(Math.random()*100)
        },
        usernameBlur(){
            if (this.username==''){
                lightyear.notify("请输入用户名","danger","500","mdi mdi-checkbox-marked-close");
                $('#username').attr("border","border")
            }
        },
        passwordBlur(){
            if (this.username==''){
                lightyear.notify("请输入密码","danger","500","mdi mdi-checkbox-marked-close");
                $('#username').attr("border","border")
            }
        },
        codeBlur(){
            if (this.username==''){
                lightyear.notify("请输入验证码","danger","500","mdi mdi-checkbox-marked-close");
                $('#username').attr("border","border")
            }
        }
    },
});
